from api.ihrmLoginApi import IhrmLoginApi
from common.assertTools import common_assert


class TestIhrmLogin(object):
    def setup_class(self):
        self.ihrm_login = IhrmLoginApi()

    def test01_login_success(self):
        req_body = {"mobile": "13800000002", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, True, 10000, "操作成功")

    def test02_login_success(self):
        req_body = {"mobile": "13800000008", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test03_login_success(self):
        req_body = {"mobile": "1380000000", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test04_login_success(self):
        resp = self.ihrm_login.login(None)
        common_assert(resp, 200, False, 99999, "系统繁忙")

    def test05_login_success(self):
        req_body = {"mobile": "13800000002", "password": "1234567"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test06_login_success(self):
        req_body = {"mobile": "138000000022", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test07_login_success(self):
        req_body = {"mobile": "None", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test08_login_success(self):
        req_body = {"mobile": "138abc00002", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test09_login_success(self):
        req_body = {"mobile": "13800000002", "password": "1"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test10_login_success(self):
        req_body = {"mobile": "13800000002",
                    "password": "1234567890123456789012345678901234567890"
                                "1234567890123456789012345678901234567890"
                                "123456789012345678901234567890"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test11_login_success(self):
        req_body = {"mobile": "13800000002", "password": "None"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test12_login_success(self):
        req_body = {"mobile": "13800000002", "password": "123456", "abc": "123"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, True, 10000, "操作成功")

    def test13_login_success(self):
        req_body = {"mobile": "13800000002", "password": "123abc"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test14_login_success(self):
        req_body = {"mobile": "13800000002"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")

    def test15_login_success(self):
        req_body = {"mobile": "13800000002", "pwd": "123456"}
        resp = self.ihrm_login.login(req_body)
        common_assert(resp, 200, False, 20001, "用户名或密码错误")
